package com.zhiban.project.controller;

import com.zhiban.project.domain.question.QuestionContent;
import com.zhiban.project.util.JsonUtil;
import com.zhiban.project.util.Object2Xml;

import dinamica.GenericTransaction;
import dinamica.Recordset;

public class GetQuestionList extends GenericTransaction {

	@Override
	public int service(Recordset inputParams) throws Throwable {
		int rc = super.service(inputParams);
		Recordset rs = this.getRecordset("query-base.sql");
		while (rs.next()) {
			Integer id = rs.getInteger("id");
			String name = rs.getString("name");
			String content = rs.getString("content");
			QuestionContent question = Object2Xml.toBean(content,
					QuestionContent.class);
			String questionStr = JsonUtil.writeObject(question);
			/*
			 * questionStr = questionStr.replaceAll("\"{",
			 * "{").replaceAll("}\"", "}");
			 */
			rs.setValue("content", questionStr);
		}
		publish("query-base.sql", rs);
		return rc;
	}
}
